<?php


namespace App\Http\Controllers\Alipay;

use App\Models\MemberOther;
use App\Services\AlipayMiniAppService;
use App\Services\AuthService;
use App\Services\CommonService;
use Illuminate\Http\Request;

class BaseController extends BaseVerifyController
{

    protected $member;
    protected $filterAction = [
        'Alipay\MyCentreController@indexList',
        'Alipay\OrderNewController@confirmOrder',
    ];

    public function __construct(Request $request)
    {
        parent::__construct($request);
        if (AuthService::checkFilter(request()->route()->action['controller'], $this->filterAction)) {
            $userToken = $request->header("token");
            if ($userToken) {
                $member = MemberOther::where(['token' => $userToken])->select('id', 'mobile', 'token', 'user_id', 'cert_name', 'cert_no', 'idcard_front', 'idcard_back')->first();
                $member = obToArray($member);
                if ($member) {
                    $this->member = $member;
                    return true;
                }
            }
            echo json_encode(['status' => CommonService::HTTP_CODE_NOT_LOGIN, 'msg' => '未授权请授权登录', 'data' => []], JSON_UNESCAPED_UNICODE);
            exit;
        }
    }


}
